package com.woniu.woniuproject.mapper;

import com.woniu.woniuproject.entity.LooseLabel;
import com.woniu.woniuproject.vo.AddLooseLabelVo;
import com.woniu.woniuproject.vo.LooselabeVo;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.springframework.stereotype.Repository;

import java.util.Date;
import java.util.List;
@Repository
public interface LooseLabelMapper {
    /**
     * 查询卫审核的散标
     * @param startDate 申请时间范围开始
     * @param endDate  申请时间范围结束
     * @return  未审核的散标
     */
    List<LooseLabel> selectByAplay(@Param("startDate") Date startDate,@Param("endDate") Date endDate,@Param("status") int status);
    List<LooseLabel> selectByAplays(@Param("startDate") Date startDate,@Param("endDate") Date endDate);

    int updateStatusByid(@Param("status") int status,@Param("labelid") int labelid);
    @Select("select * from t_loose_label where labelid =#{labelid}")
    LooseLabel selectBykey(int labelid);

@Select("select * from t_loose_label where projectnumber = #{debttypename}")
    LooseLabel selectByProjectnumber(String debttypename);
@Update("update t_loose_label set status =#{status},transferredamount=#{transferredamount} where labelid=#{labelid}")
    int updatestatusBykey(LooseLabel looseLabel);
@Update("update t_loose_label set projectnumber=#{looseLabel.projectnumber},dateinfoid=#{looseLabel.dateinfoid} where labelid=#{looseLabel.labelid}")
    void updateBykey(@Param("looseLabel") LooseLabel looseLabel);

@Update("update t_loose_label set status = #{status1} where projectnumber=#{debttypename}")
    int updateStatusBkey(@Param("debttypename") String debttypename, @Param("status1") int status1);


@Select("select * from t_loose_label")
    List<LooseLabel> selectall();
@Insert("insert into t_loose_label (debtormoney,debormoney,periods,phone,debtortypedesc,debtoruser,debtordesc,debtorname,incomerate,loanmode,repaymentmethod,debordate,deborid) " +
        "values(#{debtormoney},#{debormoney},#{debormoney},#{phone},#{fliename},#{debtoruser},#{debtordesc},#{debtorname},#{incomerate}," +
        "#{loanmode},#{repaymentmethod},#{debordate},#{deborid}) ")
    int insert(AddLooseLabelVo addLooseLabelVo);
@Update("update  t_loose_label set connection=connection+1 where labelid =#{labelid}")
    int updateByid(LooseLabel looseLabel);
    @Update("update t_loose_label set status =6 where labelid =#{labelid}")
    int updateStaByid(Integer labelid);

    List<LooseLabel> selectByWeb(@Param("ls") LooselabeVo looselabeVo);

    @Select("SELECT labelid FROM t_loose_label \n" +
            " ORDER BY labelid DESC\n" +
            " LIMIT 0,1")
    int queryByLastId();

    @Select("select * from  t_loose_label where status=4")
    List<LooseLabel> selectstatus4();

    @Update("update t_loose_label set transferredamount=#{transferredamount} where labelid =#{labelid} ")
    int updateTransferredamount(LooseLabel looseLabel);
    @Update("update t_loose_label set dateofissue=#{data} where labelid =#{labelid}")
    int updateDate(@Param("data") Date date,@Param("labelid")int labelid);
    @Update("update t_loose_label set status=#{status},loandate=#{date},endtime=#{date} where labelid=#{id}")
    void updateByids(@Param("status") int i,@Param("id") Integer labelid, @Param("date") Date date);

    @Update("update t_loose_label set repaymentNo=repaymentNo+1 where labelid =#{claimsId}")
    int updaterepaymentNo(Integer claimsId);
}
